/*
 *      noxii.cpp
 *      
 *      2009 Víctor Manuel Ochoa <kanito8a@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */


#include "noxii.h"

/*
 * 
 * name: Noxii
 * Constuctor
 */
Noxii::Noxii(): AnimedEntity()
{
	
}

/*
 * 
 * name: ~Noxii
 * Destuctor
 */
Noxii::~Noxii()
{
	
}

/*
 * 
 * name: init
 * Initializes the object
 * @param Manager* 
 * @return bool: true if the initialization went OK
 */
bool Noxii::init(Manager *_game_manager,TextureManager *_texturemanager)
{
	m_pLog=&Log::getInstance();
	
	
	AnimedEntity::init(_texturemanager,"data/cfg/noxii_body.cfg");
	m_noxii_head=new AnimedEntity();
	m_noxii_head->init(_texturemanager,"data/cfg/noxii_head_basic.cfg");

	m_noxii_weapon=new AnimedEntity();
	m_noxii_weapon->init(_texturemanager,"data/cfg/sword.cfg");

	_game_manager->addEntity(m_noxii_head);
	_game_manager->addEntity(m_noxii_weapon);
	
	m_pLog->debug("+ Noxii initialized");	

	setState(STATE_STAND);
	
	attachEntity(m_noxii_head,0);
	attachEntity(m_noxii_weapon,1);
	
	return true;	
}

/*
 * 
 * name: freeMemory
 * Liberates the memory
 */
void Noxii::freeMemory()
{
	m_noxii_head=0;
	m_noxii_weapon=0;
	m_group_manager=0;
	AnimedEntity::freeMemory();	
	m_pLog->debug("- Noxii free");
	m_pLog=0;
}

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
void Noxii::update()
{
	//~ if(m_group_manager && m_group_manager->getGroupState()!=m_state)
	//~ {
		//~ //setState(m_group_manager->getGroupState());
	//~ }

	AnimedEntity::update();	
}

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
void Noxii::setState(NoxiiState _state)
{
	m_state=_state;
	
	if(m_noxii_head)
		m_noxii_head->setAnimation((unsigned short)_state);
		
	if(m_noxii_weapon)
		m_noxii_weapon->setAnimation((unsigned short)_state);
		
	AnimedEntity::setAnimation((unsigned short)_state);	
}

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
void Noxii::setFramepoints()
{
	AnimationFramePoints frame_points[MAX_FRAME_P0INTS];
	FramePoint p;
	p.x=+2;p.y=-3;	
	frame_points[0].framePoints.push_back(p); // Frame 0
	
	p.x=+2;p.y=-3;	
	frame_points[0].framePoints.push_back(p); // Frame 1
	
	p.x=+2;p.y=-4;	
	frame_points[0].framePoints.push_back(p); // Frame 2 
	
	p.x=+2;p.y=-4;	
	frame_points[0].framePoints.push_back(p); // Frame 3
	
	p.x=+2;p.y=-3;	
	frame_points[0].framePoints.push_back(p); // Frame 4 XXX
	
	p.x=+2;p.y=-3;	
	frame_points[0].framePoints.push_back(p); // Frame 5 XXX
	
	p.x=+2;p.y=-4;	
	frame_points[0].framePoints.push_back(p); // Frame 6
	p.x=+2;p.y=-5;	
	frame_points[0].framePoints.push_back(p); // Frame 7
	p.x=+2;p.y=-6;	
	frame_points[0].framePoints.push_back(p); // Frame 8
	p.x=+2;p.y=-5;	
	frame_points[0].framePoints.push_back(p); // Frame 9
	p.x=+2;p.y=-4;	
	frame_points[0].framePoints.push_back(p); // Frame 10
	p.x=+2;p.y=-4;	
	frame_points[0].framePoints.push_back(p); // Frame 11

	// FPnumero 1
	p.x=0;p.y=0;	
	frame_points[1].framePoints.push_back(p); // Frame 0
	
	frame_points[1].framePoints.push_back(p); // Frame 1
	p.y=-1;
	frame_points[1].framePoints.push_back(p); // Frame 2 
	
	frame_points[1].framePoints.push_back(p); // Frame 3
	p.y=0;	
	frame_points[1].framePoints.push_back(p); // Frame 4 XXX
	
	frame_points[1].framePoints.push_back(p); // Frame 5 XXX
	
	p.y=0;	
	frame_points[1].framePoints.push_back(p); // Frame 6
	p.y=-1;	
	frame_points[1].framePoints.push_back(p); // Frame 7
	p.y=-2;	
	frame_points[1].framePoints.push_back(p); // Frame 8
	p.y=-2;	
	frame_points[1].framePoints.push_back(p); // Frame 9
	p.y=-1;	
	frame_points[1].framePoints.push_back(p); // Frame 10
	p.y=0;	
	frame_points[1].framePoints.push_back(p); // Frame 11

	
	AnimedEntity::setAnimationFramePoints(frame_points);
}
